package com.glc.gao.gavin.rxjavademo.operator;


import android.util.Log;
import android.view.View;

import com.glc.gao.gavin.rxjavademo.R;
import com.glc.gao.gavin.rxjavademo.operator.BaseActivity;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.BiFunction;
import io.reactivex.functions.Consumer;

public class ScanActivity extends BaseActivity {
    @Override
    public int getDescribeText() {
        return R.string.describe_scan;
    }

    @Override
    protected int getContextView() {
        return R.layout.activity_scan;
    }

    public void executeScan(View view) {

        Observable.just(1, 2, 3).scan(new BiFunction<Integer, Integer, Integer>() {
            @Override
            public Integer apply(@NonNull Integer integer, @NonNull Integer integer2) throws Exception {
                return integer + integer2;
            }
        }).subscribe(new Consumer<Integer>() {
            @Override
            public void accept(@NonNull Integer integer) throws Exception {
                print("scan " + integer + "\n");
            }
        });


    }
}
